#pragma once

#include <memory>
#include <netinet/in.h>
#include <string>
#include <sys/socket.h>
#include <unordered_map>
#include "connection.h"
#include "poll_poller.h"
class reactor_client
{
  public:
    explicit reactor_client(const std::string& ip, uint16_t port, int conn_count = 1);

    void start();

    ~reactor_client();

  private:
    void init_server_addr();

  private:
    const std::string                                    ip_;
    const uint16_t                                       port_;
    const int                                            conn_count_;
    struct sockaddr_in                                   server_addr_;
    struct sockaddr*                                     server_addr_ptr_;
    const socklen_t                                      server_addr_len_;
    poll_poller*                                         poller_;
    std::unordered_map<int, std::shared_ptr<connection>> all_connections_;
};